import { Controller, Get, Inject } from '@nestjs/common';
import { AppService } from './app.service';
import { log } from 'console';

@Controller()
export class AppController {
  // Nest会自动注入
  // constructor(private readonly appService: AppService) {}
  // 手动注入
  @Inject(AppService)
  private readonly appService: AppService;
  
  // 注入自定义的对象
  @Inject('person')
  private readonly person: {
    name: string,
    age: number
  }

  // 动态注入
  @Inject('person2')
  private readonly person2: {
    name: string,
    desc: string
  }

  // 参数注入
  @Inject('person3')
  private readonly person3: {
    name: string,
    desc: string
  }

  // 异步注入
  @Inject('person4')
  private readonly person4: {
    name: string,
    desc: string
  }

  // 别名
  @Inject('person5')
  private readonly person5: {
    name: string,
    desc: string
  }

  @Get()
  getHello(): string {
    log(this.appService);
    log(this.person);
    log(this.person2);
    return this.appService.getHello();
  }
}
